package dvsdk;

import dvsdk.db.*;
import dvsdk.form.Util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Dvsdk {

    public static void main(String[] args) {
        try { 
            
            Base base = new Base(GlobalConfig.DB_DIR+GlobalConfig.DB_NAME);
            String dbname="test";
            base.init(dbname,"name,name2");
            List<BinBase> arAdd = new ArrayList();
            String ida="md5";
            String idr="md6";
            List<BinParam> parAdd = new ArrayList();
            parAdd.add(new BinParam("name", "THISNAME"));
            parAdd.add(new BinParam("name2", "THISNAME2"));
            arAdd.add(new BinBase(idr+"-1", ida, idr, Util.getCurDate(), Util.getCurDate(), "1",parAdd));
            arAdd.add(new BinBase(idr+"-2", ida, idr, Util.getCurDate(), Util.getCurDate(), "1",parAdd));
            arAdd.add(new BinBase(idr+"-3", ida, idr, Util.getCurDate(), Util.getCurDate(), "1",parAdd));
            base.SyncAddElements(dbname, arAdd);
            arAdd.get(0).setState("4");
            base.SyncUpdElements(dbname, arAdd);
            //base.SyncDelElements(dbname, arAdd);
            List<BinBase> out = base.getAllElementsSync(dbname, "name,name2");
            for (Iterator<BinBase> it = out.iterator(); it.hasNext();) {
                BinBase binBase = it.next();
                System.out.println(binBase.getId());
            }
            base.SyncDelElements(dbname, arAdd);
            //dbname="user";
            //base.init(dbname,GlobalConfig.STD_USR_FILEDS);
            List<BinComboUser> arUserAdd = new ArrayList();
            arUserAdd.add(new BinComboUser("Иванов Иван Иванович", 0, "12345678901"));
            arUserAdd.add(new BinComboUser("Иванов Иван Иванович", 0, "12345678902"));
            arUserAdd.add(new BinComboUser("Иванов Иван Иванович", 0, "12345678903"));
            Test t = new Test();
            t.setList(arUserAdd);
            t.setVisible(true);
            
            
            //base.SyncAddElements(dbname, ida, idr, arAdd);
            ///base.

           //base.SyncDelElements(dbname, arAdd);
            
            System.out.println(base.SyncCountElements(dbname, "0"));
            base.disconnect();
        } catch (Exception ex) {
            System.err.println(ex.getLocalizedMessage());
            //Logger.getLogger(Dvsdk.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
}
